package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.FamilyMemberDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.FamilyMemberElderVo;
import com.zzyl.nursing.vo.FamilyMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "小程序用户管理")
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController {

    @Autowired
    private IFamilyMemberService familyMemberService;

    @ApiOperation("绑定家人")
    @PostMapping("/add")
    public R<String> bindElder(@RequestBody FamilyMemberDto familyMemberDto) {
        familyMemberService.bindElder(familyMemberDto);
        return R.ok();
    }

    @ApiOperation("查询家人列表")
    @GetMapping("/my")
    public R<FamilyMemberVo> selectMyFamilyList(Integer pageNum, Integer pageSize) {
        FamilyMemberVo familyMemberVo = familyMemberService.selectMyFamilyList(pageNum, pageSize);
        return R.ok(familyMemberVo);
    }

    @ApiOperation("查看家人列表")
    @GetMapping("/list-by-page")
    public R<List<FamilyMemberElderVo>>selectFamilyListByPage(Integer pageNum, Integer pageSize) {
        TableDataInfo<FamilyMemberElderVo> page = familyMemberService.selectFamilyListByPage(pageNum, pageSize);
        return R.ok(page.getRows());
    }

}
